package com.usdt.system.service.impl.cp;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.usdt.system.domain.cp.ActivityCustomerEntity;
import com.usdt.system.domain.cp.ActivityImgEntity;
import com.usdt.system.mapper.cp.ActivityCustomerMapper;
import com.usdt.system.service.cp.ActivityCustomerService;

@Service
public class ActivityCustomerServiceImpl extends ServiceImpl<ActivityCustomerMapper, ActivityCustomerEntity> 
											implements ActivityCustomerService{

	@Override
	public List<ActivityCustomerEntity> list(Integer activityId) {
		
		QueryWrapper<ActivityCustomerEntity> query = new QueryWrapper<ActivityCustomerEntity>();
		if(null!=activityId) {
			query.eq("activity_id", activityId);
		}
		List<ActivityCustomerEntity> list = baseMapper.selectList(query);
		if(CollectionUtils.isEmpty(list)) {
			list = new ArrayList<ActivityCustomerEntity>();
		}
		return list;
	}

	@Override
	public void insertList(List<ActivityCustomerEntity> list) {
		if(!CollectionUtils.isEmpty(list)) {
			for (ActivityCustomerEntity activityCustomerEntity : list) {
				baseMapper.insert(activityCustomerEntity);
			}
		}
	}

	@Override
	public void del(Integer activityId) {
		QueryWrapper<ActivityCustomerEntity> query = new QueryWrapper<ActivityCustomerEntity>();
		query.eq("activity_id", activityId);
		
		baseMapper.delete(query);
	}

	@Override
	public List<ActivityCustomerEntity> selectList(Integer activityId) {
		QueryWrapper<ActivityCustomerEntity> query = new QueryWrapper<>();
		query.eq("activity_id", activityId);
		List<ActivityCustomerEntity> selectList = baseMapper.selectList(query);
		
		return CollectionUtils.isEmpty(selectList)?new ArrayList<ActivityCustomerEntity>():selectList;
	}

}
